

// store/reducer.js
import {
  ADD_NUMBER,
  SUB_NUMBER
} from './constants.js'

const inintState = {
  counter: 0
}

// state  前一个state
export default function reducer(state = inintState, action){
  switch(action.type){
    case ADD_NUMBER:
      return {...state, counter: state.counter + action.num}
    case SUB_NUMBER:
      return {...state, counter: state.counter - action.num}
    default:
      return state
  }
}